package service

import (
	"awesomeProject/app/model"
	"awesomeProject/app/request"
	"awesomeProject/app/response"
	"awesomeProject/global"
	"context"
	"go.mongodb.org/mongo-driver/bson"
)

type OrderItemOverviewSrv struct{}

func (o OrderItemOverviewSrv) ItemOverview(req request.OrderItemOverview) response.Resp {
	filter := bson.D{{"orderSn", req.OrderSn}}
	var itemOverview model.OrderItemOverview
	err := global.MongoDB.Collection("order_item_overview").FindOne(context.TODO(), filter).Decode(&itemOverview)
	if err != nil {
		return response.ErrQuery.SetMsg(err.Error())
	}

	return response.OK.WithData(itemOverview)
}
